<?php

namespace Admin\Model;

use Think\Model;

class UserModel extends Model{

    protected $_validate = array(

        array('email','require','邮箱不能为空'),
        array('email','email','邮箱格式不正确'),
        array('email','','邮箱已经存在！',0,'unique',1),
        array('password','require','密码不能为空'),
        array('password','5,20','密码格式不正确',0,'length'),
        array('check_password','password','确认密码不正确',0,'confirm'),
    );

    protected $_auto = array (
        array('password','get_password',3,'callback') , // 对password字段在新增和编辑的时候使md5函数处理
        array('token','get_token',3,'callback'),
    );
    function get_password($password){
        return md5(trim($password));
    }
    function get_token(){
        return substr(md5(uniqid()),6,-6);
    }
}